//
//  LLGoodsDetailHeaderView.m
//  LoveLove
//
//  Created by 肖兰月 on 2019/4/6.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLGoodsDetailHeaderView.h"
#import "LLShopGoodsModel.h"

@interface LLGoodsDetailHeaderView ()<SDCycleScrollViewDelegate>
@property (strong, nonatomic) SDCycleScrollView *cycleScrollView;
@property (strong, nonatomic) UILabel *priceLbl;
@property (strong, nonatomic) UILabel *countLbl;
@property (strong, nonatomic) UILabel *titleLbl;
@property (strong, nonatomic) CALayer *separateLine;
@property (strong, nonatomic) UILabel *noteLbl;
@end


@implementation LLGoodsDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (void)initSubViews {
    _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, self.width, LLScreenWidth*315/375) delegate:self placeholderImage:nil];
    _cycleScrollView.backgroundColor = LLColorRGB(191);
    _cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
    _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    _cycleScrollView.clipsToBounds = YES;
    _cycleScrollView.pageDotColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
    //    _cycleScrollView.currentPageDotColor = FWSColor(254, 85, 46);
    //    _cycleScrollView.pageControlBottomOffset = -5;
    [self addSubview:_cycleScrollView];
    
    
    CGFloat leftMargin = 12;
    _priceLbl = [LLInitBaseViewTool labelWithText:nil textColor:nil font:0 textAlignment:NSTextAlignmentLeft];
    _priceLbl.frame = CGRectMake(leftMargin, _cycleScrollView.bottom+10, self.width-120-leftMargin, 20);
    [self addSubview:_priceLbl];
    
    _countLbl = [LLInitBaseViewTool labelWithText:nil textColor:LLColorRGB(91) font:13 textAlignment:NSTextAlignmentRight];
    _countLbl.frame = CGRectMake(self.width-120-leftMargin, _cycleScrollView.bottom+10, 120, 20);
    [self addSubview:_countLbl];
    
    _separateLine = [CALayer layer];
    _separateLine.frame = CGRectMake(0, self.height-10-41, self.width, 1);
    _separateLine.backgroundColor = LLColorRGB(238).CGColor;
    [self.layer addSublayer:_separateLine];
    
    _noteLbl = [LLInitBaseViewTool labelWithText:nil textColor:LLColorRGB(91) font:13 textAlignment:NSTextAlignmentLeft];
    _noteLbl.frame = CGRectMake(leftMargin, self.height-10-40, self.width-2*leftMargin, 39);
    [self addSubview:_noteLbl];
    
    _titleLbl = [LLInitBaseViewTool labelWithText:nil textColor:LLColorRGB(0) font:15 textAlignment:NSTextAlignmentLeft];
    _titleLbl.frame = CGRectMake(leftMargin, _priceLbl.bottom+10, LLScreenWidth-leftMargin*2, _separateLine.top-_priceLbl.bottom-20);
    _titleLbl.numberOfLines = 2;
    [self addSubview:_titleLbl];
    
    CALayer *bottomLine = [CALayer layer];
    bottomLine.backgroundColor = LLColorRGB(238).CGColor;
    bottomLine.frame = CGRectMake(0, _noteLbl.bottom, self.width, 10);
    [self.layer addSublayer:bottomLine];
}

- (void)setModel:(LLShopGoodsModel *)model {
    _model = model;
    _priceLbl.attributedText = model.attrPrice;
    _countLbl.text = model.goods_point;
    _titleLbl.text = model.goods_name;
    _noteLbl.text = model.goods_classify_name;
}

@end
